-
Notifications
You must be signed in to change notification settings - Fork 23
Add x-shadow feature for Shadow simulation compatibility #446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
|
Hi @xDimon and thanks for contributing! The issue looks to me as networking configuration problem and not as the code limitation. If the processes under Shadow share the same address space (do you mean local IP?), the nodes must be configured to listen on different ports or other bad things will happen. Reusing the same local listen port the process is already listening on should not be the problem then. Does this make sense? |
|
@dmitry-markin |
|
It's needed for paritytech/polkadot-sdk#10055 |
| socket.set_nonblocking(true)?; | ||
| socket.set_nodelay(nodelay)?; | ||
|
|
||
| #[cfg(not(feature = "x-shadow"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an existing runtime configuration for this in tcp::Config (and similarly for websocket):
litep2p/src/transport/tcp/config.rs
Line 42 in 8a02398
| pub reuse_port: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This configuration only applies to listening sockets, and it is ok. But problem happens when we are trying to bind address for outgoing sockets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It applies both to listen addresses and dial addresses.
If you really need this, I would suggest doing it in But this will break the mechanism of detecting the external address, so you will need to manually specify |
Summary
This PR introduces the
x-shadowfeature, which allows building Litep2p compatible with the Shadow network simulator.When this feature is enabled, outgoing socket binding is disabled to prevent address collisions that occur under Shadow, which otherwise lead to
AddrInUseerrors when connecting to remote peers.Changes
x-shadow.Motivation
Under the Shadow simulator, each node runs in an isolated process namespace but shares the same IP address space.
Explicitly binding outgoing sockets may cause multiple nodes to use the same source address, resulting in
EADDRINUSEcollisions.The
x-shadowfeature resolves this by skipping the bind step for outgoing connections, ensuring stable network behavior in simulation.Compatibility
--features x-shadow.Testing
--features x-shadow.